package com.peppa.petshop.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author SongTiantian
 * @create 2021-06-15-15:12
 */
@Configuration
public class FileUploadConfig implements WebMvcConfigurer {

    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        System.out.println("获取图片");
        //获取文件的真实路径
        String path ="F:\\code\\petshop01\\src\\main\\resources\\static\\images\\";
        //static/upload/**是对应resource下工程目录
        registry.addResourceHandler("/images/**").addResourceLocations("file:"+path);
        System.out.println("获取图片");

    }
}


